import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 引入路由组件
import login from '@/views/user/login.vue'
import layout from '@/views/layout.vue'
import user from '@/views/user/user.vue'
import home from '@/views/home/home.vue'
import qa from '@/views/qa/qa.vue'
import movie from '@/views/movie/movie.vue'
import notfound from '@/views/notfound/notfound.vue'
import edit from '@/views/user/edit.vue'

const routes = [
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/edit',
    name: 'edit',
    component: edit
  },
  {
    path: '/',
    name: 'layout',
    component: layout,
    children: [
      {
        path: '/user',
        name: 'user',
        component: user
      },
      {
        path: '/home',
        name: 'home',
        component: home
      },
      {
        path: '/qa',
        name: 'qa',
        component: qa
      },
      {
        path: '/movie',
        name: 'movie',
        component: movie
      },
      { 
        path: '/', 
        redirect: '/home' 
      }
    ]
  },
  {
    path: '/notfound',
    name: 'notfound',
    component: notfound
  },
  { 
    path: '*', 
    redirect: '/notfound' 
  }

]

const router = new VueRouter({
  routes
})

export default router
